package com.demo.base.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author 曳戈泰尔
 * @version 1.0
 * @description 异常类枚举
 * @date 2023/3/13 4:35 PM
 */
@AllArgsConstructor
@Getter
public enum ExceptionCodeEnum {
    sys_0001(-1, "服务器繁忙，请稍后重试", "Server is busy, please try again later"),
    sys_0002(-2, "限流操作", "Server is busy, please try again later"),
    sys_0003(-3, "参数有误", "Incorrect parameter");

    private final int code;
    private final String desc;
    private final String descEn;

    public static ExceptionCodeEnum getEnumByErrorCode(int errorCode) {
        for (ExceptionCodeEnum errorEnum : ExceptionCodeEnum.values()) {
            if (errorEnum.code == errorCode) {
                return errorEnum;
            }
        }

        return null;
    }
}
